package android.dj.lbscamera.activities;

import android.app.Activity;
import android.content.Intent;
import android.dj.lbscamera.R;
import android.dj.lbscamera.utils.Constants;
import android.dj.lbscamera.utils.UseUtils;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

public class PageLaunching extends Activity {
	private ImageView mImageView;
	private AnimationDrawable draw;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.launching);
		mImageView = (ImageView) findViewById(R.id.love);
		mImageView.setBackgroundResource(R.anim.launching_animation);
		draw = (AnimationDrawable) mImageView.getBackground();
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		UseUtils.setPreferenceIntData(getBaseContext(), Constants.NAME,
				Constants.KEY, 1);

		Handler handler = new Handler();
		handler.postDelayed(new Runnable() {
			public void run() {
				if (draw.isRunning()) {
					draw.stop();
				} else {
					draw.stop();
					draw.start();
				}
			}
		}, 100);
		handler.postDelayed(new Runnable() {
			public void run() {
				Intent intent = new Intent(PageLaunching.this, PageLogin.class);
				intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
				intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(intent);
				finish();
			}
		}, 4000);

	}

}
